//
//  LVNewPushShareListVc.m
//  LEVE
//
//  Created by 上官惠阳 on 2017/3/7.
//  Copyright © 2017年 dashuju. All rights reserved.
//

#import "LVNewPushShareListVc.h"
#import "LVImpModel.h"
#import "LVShareModel.h"
#import "LVImpListCell.h"
#import "LVSessionCell.h"

@interface LVNewPushShareListVc ()
@property (copy,nonatomic)void (^closeNewShareBlock)(id obj);
@end

@implementation LVNewPushShareListVc
{
    id _delegate;
}
- (instancetype)initWithTarget:(id)delegate close:(void (^)(id obj))close
{
    self = [super init];
    if (self) {
        _delegate = delegate;
        _closeNewShareBlock = close;
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    //顶部细线
    UIView *topline = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 1)];
    topline.backgroundColor = KGrayColor;
    [self.view addSubview:topline];

    self.refreshType = HYBaseTableVcRefreshTypeRefreshAndLoadMore;

    [self loadData];
}
- (void)loadData
{
    for (int i = 1; i <= 5; i++) {
        LVImpModel *model = [[LVImpModel alloc] init];
        for (int j = 0; j < i; j ++) {
            LVShareModel *m = [[LVShareModel alloc] init];
            [model.shareModelArr addObject:m];
        }
        [self.dataArray addObject:model];
    }

    [self HY_reloadData];
}
#pragma mark refresh
- (void)HY_refresh
{
    [super HY_refresh];

    [self.dataArray removeAllObjects];
    [self loadData];

    [self HY_endRefresh];
}
- (void)HY_loadMore
{
    [super HY_loadMore];

    [self loadData];

    [self HY_endLoadMore];
}
#pragma mark - UITableViewDelegate
- (NSInteger)HY_numberOfSections {
    return 1;
}

- (NSInteger)HY_numberOfRowsInSection:(NSInteger)section {
    return self.dataArray.count;
}

- (HYBaseTableViewCell *)HY_cellAtIndexPath:(NSIndexPath *)indexPath {
    LVImpModel *model = self.dataArray[indexPath.row];
    LVImpListCell *cell = [LVImpListCell nibCellWithTableView:self.tableView];
    [cell loadCellWithModel:model];

    cell.seleteShareBlock = ^(LVShareModel *model){

    };
    return cell;
}

- (CGFloat)HY_cellheightAtIndexPath:(NSIndexPath *)indexPath {
    return 77;
}
- (UIView *)HY_headerAtSection:(NSInteger)section
{
    LVSessionCell *sessionView = [LVSessionCell nibCellWithTableView:self.tableView];
    [sessionView setCountLabelText:@"23"];

    sessionView.backgroundColor = [UIColor whiteColor];
    sessionView.leftTitleLabel.text = @"来自朋友的分享";
    sessionView.rightActionBlock = ^(BOOL seleted){
        if (_closeNewShareBlock) {
            _closeNewShareBlock(nil);
        }
    };
    return sessionView;
}
- (CGFloat)HY_sectionHeaderHeightAtSection:(NSInteger)section
{
    return 40;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
